//不要给我WA WA 叫
//一定AC
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <iomanip>
#include <climits>
#define int long long 
#define x first 
#define y second 
using namespace std;
const int N = 1e5 + 10;
const int MOD = 1e9 + 7;
int a[N];
void solve()
{
    int n;
    cin >> n;
    string s;
    unordered_map<int,int> mp;
    for(int i = 1; i <= n; i++)
    {
        cin >> s;
        int m = s.size();
        mp[m]++;
    }
    int ans = 1;
    for(auto c:mp)
    {
        if(c.y >= 2)
        {
             for(int i = c.y; i >= 1; i--)
             {
                  ans = (ans * i) % MOD; 
             }
        }
    }
    cout << ans % MOD << endl;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr),cout.tie(nullptr);
    int t = 1;
    while(t -- )  solve();
    return 0;
}
